import { parseNumberSentence } from '../../util/dictation'

function runTests() {
  const tests = [
    ['zero', 0],
    ['one', 1],
    ['two', 2],
    ['three', 3],
    ['four', 4],
    ['five', 5],
    ['ten', 10],
    ['eleven', 11],
    ['twenty', 20],
    ['twenty-one', 21],
    ['thirty-five', 35],
    ['ninety-nine', 99],
    ['one hundred', 100],
    ['one hundred and one', 101],
    ['two hundred', 200],
    ['three hundred and fifty', 350],
    ['one thousand', 1000],
    ['one thousand two hundred', 1200],
    ['eleven hundred', 1100],
    ['ten thousand', 10000],
    ['twelve thousand three hundred', 12300],
    ['a hundred and fifty', 150],
    ['twenty thousand', 20000],
    ['fifty thousand', 50000],
    ['one million', 1000000],
    ['two million three hundred', 2000300],
    ['a billion', 1000000000],
    ['one billion two hundred million', 1200000000],
    ['two thousand two hundred and twenty-two', 2222],
    ['three hundred thousand', 300000],
    ['forty-five million six hundred thousand', 45600000],
    [
      'seven hundred seventy-seven thousand seven hundred seventy-seven',
      777777,
    ],
    [
      'nine hundred ninety-nine billion nine hundred ninety-nine million nine hundred ninety-nine thousand nine hundred ninety-nine',
      999999999999,
    ],
    ['fifty', 50],
    ['twenty one', 21],
    ['fifty five', 55],
    ['ninety nine', 99],
    ['a hundred', 100],
    ['a hundred and one', 101],
    ['twelve hundred', 1200],
    ['twenty five thousand', 25000],
    ['two million', 2000000],
    ['one billion', 1000000000],
    ['one million two hundred thousand', 1200000],
    ['two billion three million', 2003000000],
    ['fifty million twenty thousand', 50020000],
    ['one hundred and fifty', 150],
    ['one thousand and one', 1001],
    ['one million and one', 1000001],
    ['forty-two', 42],
    ['a hundred thousand', 100000],
    ['a thousand', 1000],
    ['a thousand two hundred', 1200],
    ['a thousand a hundred', 1100],
    ['a million a thousand a hundred', 1001100],
    ['8', 8],
    ['42', 42],
    ['100', 100],
    ['8 billion', 8000000000],
    ['5 hundred', 500],
    ['12 thousand', 12000],
    ['1 million', 1000000],
    ['8 billion 5 million', 8005000000],
    ['5 hundred thousand', 500000],
    ['12 thousand 5 hundred', 12500],
    ['1 million 5 hundred thousand', 1500000],
    ['a hundred 50', 150],
    ['50 thousand a hundred', 50100],
    ['a million 5 thousand', 1005000],
    ['1.5 million', 1500000],
    ['2.5 billion', 2500000000],
    ['3.7 thousand', 3700],
    ['8.5 billion 3 million', 8503000000],
    ['1.5 million 200 thousand', 1700000],
    ['2 billion 500 million', 2500000000],
    ['0.5 million', 500000],
    ['0.25 billion', 250000000],
    ['1.75 hundred', 175],
    ['1 quadrillion', 1000000000000000],
    ['1,5 quadrillion', 1500000000000000],
    ['0,5 quadrillion', 500000000000000],
    ['1,5 quadrillion 2,5 trillion', 1502500000000000],
    ['2,5 trillion 500 billion', null],
    ['1 trillion 500,5 billion', 1500500000000],
    ['1,234,5 billion 2,5 million', 1234502500000],
    ['a hundred 50,5', 150.5],
    ['0,5 trillion', 500000000000],
    ['1,000,5 billion', 1000500000000],
    ['ten trillion and 24', 10_000_000_000_024],
    ['eleven billion forty-two', 11_000_000_042],
    ['2,321', 2321],
    ['0,001 quadrillion', 1000000000000],
    ['0,1 quadrillion', 100000000000000],
    ['0,01 trillion', 10000000000],
    ['0,001 trillion', 1000000000],
    ['234,1', 234.1],
    ['1,5 million', 1500000],
    ['2,5', 2.5],
    ['10,5 billion', 10500000000],
    ['234,1 thousand', 234100],
    // ['1,5 billion two million', 1_502_000_000],
    ['2,5 hundred', 250],
    ['1,234', 1234],
    ['1,234,567', 1234567],
    ['1,234,567.89', 1234567.89],
    // ['1,234 million', 1234000000],
    ['1,234,5', 1234.5],
    ['1,234,567,8', 1234567.8],
    ['1,234,5 thousand', 1234500],
    ['1 trillion', 1000000000000],
    ['1,5 trillion', 1500000000000],
    ['two trillion', 2000000000000],
    ['1,234,567,8 billion', 1234567800000000],
  ]

  tests.forEach(([input, expected], index) => {
    const result = parseNumberSentence(input as string)

    // eslint-disable-next-line no-console
    console.assert(
      result === expected,
      `Test ${index + 1} failed: ${input} => ${result} (expected: ${expected})`
    )
  })
}

runTests()
